package me.green.util;

import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.StyleSheet;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;

/**
 * 样式定义及支持
 *
 * @author green
 */
public class CssStyle {


    /**
     * 得到默认的多条条目显示的CSS样式表
     *
     * @return
     */
    public static HTMLEditorKit defaultItemCssStyle() {
        HTMLEditorKit kit = new HTMLEditorKit();

        StyleSheet styleSheet = new StyleSheet();
        Reader reader = null;
        try {
            reader = new InputStreamReader(CssStyle.class.getResourceAsStream("/style.css"));
            styleSheet.loadRules(reader, CssStyle.class.getResource("/style.css"));
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (null != reader) {
                try {
                    reader.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        kit.setStyleSheet(styleSheet);
        return kit;
    }

}
